﻿using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(PetDataAsset))]
public class PetDataAssetEditor : Editor {

	private PetDataAsset asset;
	
	void Awake()
	{
		asset = (PetDataAsset)target;
	}
	
	public override void OnInspectorGUI()
	{
		EditorGUILayout.LabelField("SN", asset.SN.ToString());
		asset.ShowName = EditorGUILayout.TextField("显示名字", asset.ShowName);
		
		// see http://answers.unity3d.com/questions/22167/gameobject-array-in-editor-gui.html
		//     http://answers.unity3d.com/questions/26207/how-can-i-recreate-the-array-inspector-element-for.html#answer-220601
		serializedObject.Update();
		SerializedProperty m_Property = serializedObject.FindProperty("SkillPool");
		EditorGUILayout.BeginVertical();
	    do {
	      if (m_Property.propertyPath != "SkillPool" && !m_Property.propertyPath.StartsWith("SkillPool" + ".") ) {
	          break;
	      }  
	      EditorGUILayout.PropertyField(m_Property);
	    } while (m_Property.NextVisible(true));
    	EditorGUILayout.EndVertical();
		serializedObject.ApplyModifiedProperties();

		if (GUI.changed)
		{
			EditorUtility.SetDirty(asset);
		}
	}
}
